package com.dream.wuliu.base;

import org.androidannotations.annotations.EApplication;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;

import com.dream.wuliu.view.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.download.HttpClientImageDownloader;
/**
 * 
 * @author EvanYu
 *
 */
@EApplication
public class MyApplication extends Application {

	public void onCreate() {
		
		super.onCreate();
		initImageLoader();
	}

	public  String getStr(int id){
		return getApplicationContext().getString(id);
	}
	
	public  void initImageLoader() {
		Context context = this.getApplicationContext();
		DisplayImageOptions options = new DisplayImageOptions.Builder()
				.cacheInMemory().cacheOnDisc()
				.bitmapConfig(Bitmap.Config.RGB_565)
				.showImageOnFail(R.drawable.pic_default)
				.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
				.showImageForEmptyUri(R.drawable.pic_default).build();

		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				context)
				.imageDownloader(
						new HttpClientImageDownloader(context,
								new DefaultHttpClient()))
				.defaultDisplayImageOptions(options)
				.denyCacheImageMultipleSizesInMemory().build();
		ImageLoader.getInstance().init(config);
	 
	}
}
